﻿using System.Windows.Forms;

partial class SqlServerConnectionStringEditor : UserControl
{
    public SqlServerConnectionStringEditor()
    {
        InitializeComponent();
    }

    public SqlServerConnectionStringEditor(string connectionString)
    {
        InitializeComponent();

        SqlServerlConnectionStringBuilder builder = new SqlServerlConnectionStringBuilder(connectionString);

        tbServer.Text = builder.Source;
        tbDatabase.Text = builder.Catalog;
        tbUid.Text = builder.Id;
        tbPwd.Text = builder.Password;
    }

    public override string ToString()
    {
        // http://www.connectionstrings.com/sql-server-2008
        return string.Format("Data Source={0};Initial Catalog={1};User Id={2};Password={3};",
            tbServer.Text,
            tbDatabase.Text,
            tbUid.Text,
            tbPwd.Text);
    }
}
